echo "killing old dzq-installer ..."

ds=$(docker ps -a | grep "dzq-installer" | awk '{print $1}')

if [ -n "$ds" ]; then
    echo $ds | xargs docker rm -f
fi

echo "Starting php 7.4.debug..."

docker run -d \
  --name dzq-installer-web \
  -p 80:80 \
  -v $PWD:/app/discuz/public \
  -v $PWD/dzq-nginx.conf:/opt/docker/etc/nginx/vhost.conf \
  -e XDEBUG_REMOTE_HOST=host.docker.internal \
  -e XDEBUG_REMOTE_AUTOSTART=1 \
  -e XDEBUG_REMOTE_PORT=9000 \
  -e PHP_DEBUGGER=xdebug \
  -e XDEBUG_REMOTE_CONNECT_BACK=0 \
  -e PHP_DISMOD=opcache \
  -e PHP_UPLOAD_MAX_FILESIZE=100M \
  webdevops/php-nginx-dev:7.4

docker exec -it $(docker ps -f name=dzq-installer-web -q) /bin/bash -c "chown -R application:application /app/discuz"

docker run -d \
    --name dzq-installer-mysql \
    --network=container:dzq-installer-web \
    -e MYSQL_ROOT_PASSWORD=root \
    mysql:5.7 